package edu.suda.xsap.service.impl;

import edu.suda.xsap.dto.ScheduleRecordDto;
import edu.suda.xsap.dto.convert.ScheduleRecordConvert;
import edu.suda.xsap.entity.ScheduleRecord;
import edu.suda.xsap.mapper.ScheduleRecordMapper;
import edu.suda.xsap.service.ScheduleRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ScheduleRecordServiceImpl implements ScheduleRecordService{

    @Autowired
    ScheduleRecordMapper scheduleRecordMapper;
    @Autowired
    ScheduleRecordConvert scheduleRecordConvert;
    @Autowired
    CourseServiceImpl courseService;
    @Autowired
    EmployeeServiceImpl employeeService;

    @Override
    public void save(ScheduleRecord scheduleRecord) {
        scheduleRecordMapper.save(scheduleRecord);
    }
    @Override
    public ScheduleRecordDto findById(Integer id) {
        ScheduleRecord scheduleRecord=scheduleRecordMapper.findById(id);
        return scheduleRecordConvert.toDto(scheduleRecord);
    }
    @Override
    public void update(ScheduleRecord scheduleRecord) {
        scheduleRecordMapper.update(scheduleRecord);
    }
    @Override
    public void delete(Integer id) {
        scheduleRecordMapper.delete(id);
    }
    @Override
    public List<ScheduleRecordDto> findAll() {
        List<ScheduleRecord> scheduleRecords=scheduleRecordMapper.findAll();
        return scheduleRecordConvert.toDtoList(scheduleRecords);
    }


}
